﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RuleCode.Table;

namespace map.member
{
    public partial class FriendInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof (AjaxFunction ));
            if (!IsPostBack)
            {
                Literal_map.Text = RuleCode.Util.getmapurl();
                InitFriendInfo();
            }
        }

        #region 辅助方法
        /// <summary>
        /// 初始化信息
        /// </summary>
        private void InitFriendInfo()
        {
            if (Request["id"] != null)
            {
                cbuser user = cbuser.Find("recid="+Request ["id"]);           //用户RECID
                if (user.Count > 0)
                {
                    this.FriendNickHyperLink.Text = (user.cbusernickname .Value=="")?user.cbname.Value :user.cbusernickname .Value ;
                    this.NameLabel.Text = user.cbname.Value;
                    this.NickLabel.Text = user.cbusernickname.Value;
                    this.EmailLabel.Text = user.cbuserid.Value;
                    this.MobilePhoneLabel.Text = user.jcmobile.Value;
                    this.QQNumberLabel.Text = user.cbqq.Value;
                    this.MSNNumberLabel.Text = user.cbmsn.Value;
                    this.LastEmployeeLabel.Text = user.LastEmployeeName.Value;
                    this.JSchollLabel.Text = user.JuniorSchoolName.Value;
                    this.JSchollYearLabel.Text = (user.JuniorSchoolGraduateYear.ToString()=="1970")?"":(user.JuniorSchoolGraduateYear.ToString());
                    this.SSchollLabel.Text = user.SeniorSchoolName.Value;
                    this.SSchollYearLabel.Text = (user.SeniorSchoolGraduateYear.ToString() == "1970") ? "" : (user.SeniorSchoolGraduateYear.ToString());
                    this.CollageLabel.Text = user.ColleageName.Value;
                    this.CollageYearLabel.Text = (user.ColleageGraduateYear.ToString() == "1970") ? "" : (user.ColleageGraduateYear.ToString());
                    this.ProvinceLabel.Text = user.省编码.Value;
                    this.CityLabel.Text = user.县编码.Value;
                    this.DistrictLabel.Text = user.区编码.Value;
                    this.AreaLabel.Text = user.区域编码.Value;
                    this.UserBizAreaLabel.Text = user.cbUserBizArea.Value;
                    this.LatLabel.Text = user.taobaolat.Value.ToString ();
                    this.LngLabel.Text = user.taobaolong.Value.ToString();
                    this.SexLabel.Text = user.cbsex.Value;
                }

                if (AliApi.appUserId != null)
                {
                    cbuser user0 = cbuser.Find("recid="+Request ["id"]+" and cbuserid in (select cbuserid from cbusergrouplist where cbusergroupid in (select cbusergroupid from cbusergroup where cbuserid='"+AliApi .appUserId +"'))");
                    if (user0.Count > 0)
                    {
                        this.AddToFriendDiv0.Visible = false;
                        this.AddToFriendDiv1.Visible = false;
                        this.IsFriendLabel.Text = "好友：";
                    }
                    else
                    {
                        this.AddToFriendDiv1.Visible = true;
                        this.AddToFriendDiv0.Visible = true; 
                        this.IsFriendLabel.Text = "";
                    }
                }
            }
        }
        #endregion

    }
}
